var map = new WeakMap()
var innerObj = {}
class Article {
	set data(data) {
		map.set(this, {...map.get(this), ...data})
	}
	get data() {
		if(!map.has(this))  {
			console.log('data not has ')
			map.set(this, {})
		}
		return map.get(this)
	}

	set host(url) {
		if (!/^https?:\/\//i.test(url)) {
			throw new Error("网址错误");
		}
		this.data = {host:url}
	}

	get host() {
		return this.data.host
	}


	set name(name) {
		this.data = {name}
	}

	get name() {
		return this.data.name
	}

	set user(user) {
		this.data = {user}
	}
	get user() {
		return this.data.user
	}

	set sayHello(sayHello) {
		this.data = {sayHello}
	}
	get sayHello() {
		return this.data.sayHello
	}
}


function sayHello(argument) {
	return "sayHello " + ( '' + Math.random() ).slice(-4)
}

var a = new Article();
console.log(a.sayHello)
a.sayHello = sayHello
console.log(a.sayHello)

a.user = {
	name: "刘阿勇",
	age: 33,
	addr: "湖南长沙"
}

console.log(a.name)
console.log(a.user)
console.log(a.host)

a.host = 'https://baidu.com'
console.log(a.host)



console.log('-----------------------\n')
var b = map.get(a);
console.log(b.sayHello)
console.log(b)

console.log(map)
console.log(innerObj)

console.log('-----------------------\n')

a.data = 333
console.log(a.data)
console.log(map)
console.log(innerObj)
